-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FMT_VARIADIC_CONST - Support for const variadic methods #591
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but could you format the code according to the coding style: Please format according to our coding style: https://github.com/fmtlib/fmt/blob/master/CONTRIBUTING.rst (mostly Google style).
Thanks for contributing!
fmt/format.h
Outdated
@@ -3647,35 +3647,35 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED; | |||
#else | |||
// Defines a wrapper for a function taking __VA_ARGS__ arguments | |||
// and n additional arguments of arbitrary types. | |||
# define FMT_WRAP(Char, ReturnType, func, call, n, ...) \ | |||
# define FMT_WRAP(Const,Char, ReturnType, func, call, n, ...) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing space after ,
fmt/format.h
Outdated
fmt::internal::ArgArray<n>::Type arr; \ | ||
FMT_GEN(n, FMT_ASSIGN_##Char); \ | ||
call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList( \ | ||
fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), arr)); \ | ||
} | ||
|
||
# define FMT_VARIADIC_(Char, ReturnType, func, call, ...) \ | ||
inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__)) { \ | ||
# define FMT_VARIADIC_(Const,Char, ReturnType, func, call, ...) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
fmt/format.h
Outdated
@@ -3706,10 +3706,16 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED; | |||
\endrst | |||
*/ | |||
#define FMT_VARIADIC(ReturnType, func, ...) \ | |||
FMT_VARIADIC_(char, ReturnType, func, return func, __VA_ARGS__) | |||
FMT_VARIADIC_(,char, ReturnType, func, return func, __VA_ARGS__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
Sure, done. Sorry for this, I overlooked it. |
test/format-test.cc
Outdated
TEST(FormatTest, ConstFormatMessage) { | ||
test_class c; | ||
EXPECT_EQ("[42] something happened", | ||
c.format_message(42, "{} happened", "something")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please use 2-space indent instead of tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. It's interesting because it's copy-paste from your code. Visual studio had to reformat it.
Merged, thanks! |
You're welcome. And thank you for your patience, this was my first public PR ;-) |
Implementation of FMT_VARIDIC_CONST as discussed here #589